package com.itheima.utils;

import com.itheima.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(value = TliasException.class)
    public Result abc(TliasException e) {
        e.printStackTrace();
        return Result.error(e.getMessage());
    }

    //处理异常
    @ExceptionHandler
    public Result ex(Exception e) {
        e.printStackTrace();//打印堆栈中的异常信息

        return Result.error("对不起,操作失败,请联系管理员");
    }

}
